import com.sun.deploy.security.SelectableSecurityManager;

import java.util.Scanner;

public class Test20230808_4 {
    public static void main(String[] args){
        Scanner scanner = new Scanner(System.in);
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        int c = a>b? b:a;
        for(int i = 0; i<10000; i++){
            if(a%c==0 && b%c==0){
                System.out.println(c);
                break;

            }
            else
                c--;
        }

    }
}
